package restaurant;

import restaurant.iterators.Iterator;

/**
 * The Class cmdMenuByVegetarian.
 * 
 * @author Ebonie
 */

public class cmdMenuByVegetarian implements Command
{

	/** The info. */
	private InformationAggregator info;



	/**
	 * Instantiates a new cmd menu by vegetarian.
	 * 
	 * @param info the info
	 */
	public cmdMenuByVegetarian(InformationAggregator info) {
		this.info = info;
	}



	/**
	 * Execute.
	 * 
	 * @return the vegetarian menu.
	 * @see restaurant.Command#execute()
	 */
	@Override
	public Object execute()
	{
		Menu menu = info.getMenu();
		Iterator vegetarianIterator = menu.getByVegetarianIterator();
		MenuItem item;
		Menu vegetarianMenu = new Menu();

		while (vegetarianIterator.hasNext()) {
			item = (MenuItem) vegetarianIterator.next();

			if (item.isAvailable())
				vegetarianMenu.add(item);
		}

		return vegetarianMenu;
	}

}
